<!DOCTYPE html>
<html>
<head>
    <link rel="import" href="../include/_head.html?__inline">
</head>
<body>
<div class="jx-form-wrap">
    <div class="jx-form-container">
        <form class='jxform' method="post" action="../mock/form.php"
              data-options="{maskTarget:$('body')}">

            <div class='form-header'>
                <div class='heading'>
                    <strong>创建文章</strong>
                </div>
            </div>

            <table class='table table-form'>

                <tr>
                    <th class='w-110px'>发布名称</th>
                    <td>
                        <input name='name' class='form-control'
                               maxlength="5"
                               data-validate="{required: [true,'请输入发布名称'],maxlength: [5,'发布名称长度不能超过{0}个字符']}"
                               autofocus autocomplete='off'/>
                    </td>
                </tr>
                <tr>
                    <th>身份证</th>
                    <td>
                        <input name='idnum' class='form-control'
                               maxlength="18"
                               data-validate="{required: true,idNumber:true}"
                               autofocus autocomplete='off'/>
                    </td>
                </tr>

                <tr>
                    <th>版本</th>
                    <td>
                        <select name='build' id='build' class='form-control chosen'>
                            <option value='' selected='selected' data-keys=' '>请选择</option>
                            <option>张三</option>
                            <option>李四</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th>发布日期</th>
                    <td><input type='text' name='date' id='date' value='2017-12-09' class='form-control form-date'/>
                    </td>
                </tr>
                <tr>
                    <th>描述</th>
                    <td>
                        <textarea name='desc' id='desc' rows='10' style="resize: none" class='form-control'></textarea>
                    </td>
                </tr>
                <tr>
                    <th>附件</th>
                    <td><span class="color-red">因为安全原因，Demo暂时不支持上传附件功能！</span></td>
                </tr>

            </table>

            <div class="form-footer pl-130">
                <button class="btn btn-primary" type="submit">
                    <i class="fa fa-save"></i> 保存
                </button>
                <button class="btn btn-default" type="button">
                    <i class="fa fa-sign-in"></i> 返回
                </button>

                <a class="btn btn-default jxlink" href="page/editmore.html" title="大表单">
                    更多
                </a>
                <a class="btn btn-default jxlink" href="page/articleedit.html" title="文章编辑">
                    文章编辑
                </a>
            </div>
        </form>
    </div>
</div>
<script>
    jx.ready(function () {

        $('form').on('beforesubmit', function () {
            var d = jx.serialize($(this));
            if (d.name == '22') {
                jx.alert('请输入');
                return false;
            }
        }).on('aftersubmit', function (e, result) {
            if (result.success) {
                window.location.href = 'grid.html';
            }
            else {
                jx.alert(result.message);
            }
        });

    });
</script>
</body>
</html>
